// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router' //自动扫描里面的路由配置
import axios from './js/axios.js'
import VueAxios from 'vue-axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueCookies from "vue-cookies";
import './assets/css/mobile.css'; // 全局css

Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(VueAxios, axios)
Vue.use(VueCookies);

router.beforeEach((to, from, next) => {
  if (to.path === '/'||to.path === '/login'|| to.path === '/register'  || to.path.includes('/getshare') ||to.path.includes('/re_pwd')) {
    next();
  } else {
    if (VueCookies.get("TOKEN") === null) {
      next('/login');

    }
    next();
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App),
})
Vue.prototype.notification = function (type, msg) {//changeData是函数名
  if (type === true) {
    this.$notify({
      title: '成功',
      message: msg,
      type: 'success'
    });
  } else {
    this.$notify.error({
      title: '失败',
      message: msg
    });
  }

}

